<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="postList">
      <el-table-column type="selection" width="55" />
      <el-table-column label="终端" prop="type" />
      <el-table-column label="店铺" prop="shopName" />
      <el-table-column label="操作" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-remove-outline"
            @click="onSubmitAudit(scope.row.id)"
            >审核通过</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      v-show="total > 0"
      :total="total"
      v-model:page="page.pageNum"
      v-model:limit="page.pageSize"
      @change="getList"
    />
  </div>
</template>

<script>
  import { getList, submitPublish } from '@/api/ma/index.js';

  export default {
    name: 'Manage',
    dicts: ['sys_shop_status'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 弹出层标题
        title: '',
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          shopCode: undefined,
          shopName: undefined,
          status: undefined,
        },
        page: {
          pageNum: 1, // 当前页数
          pageSize: 10, // 每页显示多少条
        },
        // 表单参数
        form: {},
        postList: [],
      };
    },
    created() {
      this.getList();
    },
    methods: {
      // 审核通过
      onSubmitAudit(id) {
        submitPublish(id).then(() => {
          this.$modal.msgSuccess('审核通过');
          this.getList();
        });
      },
      /** 查询店铺列表 */
      getList() {
        this.loading = true;
        getList(this.page, this.queryParams).then((response) => {
          this.postList = response.records;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 表单重置
      reset() {
        this.queryParams = {
          shopCode: undefined,
          shopName: undefined,
          status: undefined,
        };
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.page.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.reset();
        this.handleQuery();
      },
    },
  };
</script>
